/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Alex
 */
@Entity
@Table(name = "T02_PROJECTS")
@NamedQueries({
    @NamedQuery(name = "Project.findAll", query = "SELECT p FROM Project p"),
    @NamedQuery(name = "Project.findByProjId", query = "SELECT p FROM Project p WHERE p.projId = :projId"),
    @NamedQuery(name = "Project.findByProjName", query = "SELECT p FROM Project p WHERE p.projName = :projName"),
    @NamedQuery(name = "Project.findByDescription", query = "SELECT p FROM Project p WHERE p.description = :description"),
    @NamedQuery(name = "Project.findByStartDate", query = "SELECT p FROM Project p WHERE p.startDate = :startDate")})
public class Project implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "PROJ_ID")
    private Long projId;
    @Column(name = "PROJ_NAME")
    private String projName;
    @Column(name = "DESCRIPTION")
    private String description;
    @Column(name = "START_DATE")
    @Temporal(TemporalType.DATE)
    private Date startDate;
    @Column(name="ITERATION_LEN")
    private Long iterationLen;

    @Column(name="ITERATION_START")
    @Temporal(TemporalType.TIMESTAMP)
    private Date iterationStart;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "projId", fetch=FetchType.LAZY)
    private List<ProjColumn> projColumnList;

    public Project() {
    }

    public Project(Long projId) {
        this.projId = projId;
    }

    public Long getProjId() {
        return projId;
    }

    public void setProjId(Long projId) {
        this.projId = projId;
    }

    public String getProjName() {
        return projName;
    }

    public void setProjName(String projName) {
        this.projName = projName;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Date getStartDate() {
        return startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public List<ProjColumn> getProjColumnList() {
        return projColumnList;
    }

    public void setProjColumnList(List<ProjColumn> projColumnList) {
        this.projColumnList = projColumnList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (projId != null ? projId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Project)) {
            return false;
        }
        Project other = (Project) object;
        if ((this.projId == null && other.projId != null) || (this.projId != null && !this.projId.equals(other.projId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Project[projId=" + projId + "]";
    }

    /**
     * @return the iterationLen
     */
    public Long getIterationLen() {
        return iterationLen;
    }

    /**
     * @param iterationLen the iterationLen to set
     */
    public void setIterationLen(Long iterationLen) {
        this.iterationLen = iterationLen;
    }

    /**
     * @return the iterationStart
     */
    public Date getIterationStart() {
        return iterationStart;
    }

    /**
     * @param iterationStart the iterationStart to set
     */
    public void setIterationStart(Date iterationStart) {
        this.iterationStart = iterationStart;
    }

}
